Skip to content

fix(cache): release compilation-scoped plugin state on rebuild#14788

Closed
matthewdavis-oai wants to merge 1 commit into
web-infra-dev:mainfrom
matthewdavis-oai:matthewdavis-oai/rspack-compilation-cache-cleanup
Closed

fix(cache): release compilation-scoped plugin state on rebuild#14788
matthewdavis-oai wants to merge 1 commit into
web-infra-dev:mainfrom
matthewdavis-oai:matthewdavis-oai/rspack-compilation-cache-cleanup

Conversation

@matthewdavis-oai

Copy link
Copy Markdown
Contributor

Summary

Release compilation-scoped plugin maps when a watch rebuild replaces the preceding compilation.

The native CSS, SRI, and Rsdoctor plugins retain several maps keyed by monotonically increasing CompilationId; the corresponding entries were not fully removed from clear_cache(old_id). Repeated rebuilds can therefore retain hooks, integrity/context state, or diagnostic/module metadata for every prior generation.

This change uses the existing plugin lifecycle hook and only removes state for the completed compilation:

  • CSS: COMPILATION_HOOKS_MAP;
  • SRI: COMPILATION_INTEGRITY_MAP and COMPILATION_CONTEXT_MAP;
  • Rsdoctor: module, entrypoint, JSON-size, and active-export-usage maps alongside the existing hook-map cleanup.

No public API, option, or compilation behavior changes.

Validation

  • Source audit/regression confirms every compilation-keyed map in these three plugins has a matching removal (8/8 entries cleared; seven were previously missing).
  • An optimized native-binding watch smoke enables native CSS, SRI, Rsdoctor, and HMR, performs repeated edits, and verifies emitted updates and diagnostics remain correct.
  • rustfmt --edition 2024 --check crates/rspack_plugin_css/src/plugin/impl_plugin_for_css_plugin.rs crates/rspack_plugin_sri/src/lib.rs crates/rspack_plugin_rsdoctor/src/plugin.rs and git diff --check pass.

This is independent of the ModuleGraphConnectionWrapper lifecycle fix in #14772.

@matthewdavis-oai

Copy link
Copy Markdown
Contributor Author

Superseded by #14772, where the validated changes are now stacked for a single review surface.

@matthewdavis-oai matthewdavis-oai deleted the matthewdavis-oai/rspack-compilation-cache-cleanup branch July 14, 2026 18:50
@codspeed-hq

codspeed-hq Bot commented Jul 14, 2026

Copy link
Copy Markdown
Contributor

Merging this PR will not alter performance

✅ 43 untouched benchmarks
⏩ 47 skipped benchmarks1


Comparing matthewdavis-oai:matthewdavis-oai/rspack-compilation-cache-cleanup (7d23f7b) with main (03080ba)

Open in CodSpeed

Footnotes

  1. 47 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase, click here and archive them to remove them from the performance reports.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant